package ltd.newbee.mall.dao;

import ltd.newbee.mall.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

@Mapper
public interface UserMapper {

    List<User> selectUserList(Map<String, Object> params);

    User selectUserById(Long userId);

    User selectUserByUserName(String userName);

    int insertUser(User user);

    int updateUser(User user);

    int deleteUser(Long userId);

    int batchDeleteUser(Long[] userIds);

    // 用户角色相关
    List<Long> selectRoleIdsByUserId(Long userId);

    int deleteUserRoleByUserId(Long userId);

    int batchInsertUserRole(@Param("userId") Long userId, @Param("roleIds") List<Long> roleIds);

    List<User> selectUsersByRoleId(Long roleId);

    /**
     * 统计用户角色数量
     */
    int countUserRoles(@Param("userId") Long userId,@Param("roleId") Long roleId);

}
